package com.huluobo.high3videoproject.mvp.like.view;


import android.util.Log;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.huluobo.base.view.BaseFragment;
import com.huluobo.high3videoproject.R;
import com.huluobo.high3videoproject.adapter.LikeVideoAdapter;
import com.huluobo.high3videoproject.adapter.VideoCardAdapter;
import com.huluobo.high3videoproject.bean.LikeVideoBeanResult;
import com.huluobo.high3videoproject.mvp.like.presenter.LikeVideoContract;
import com.huluobo.high3videoproject.mvp.like.presenter.LikeVideoPresenter;

import java.util.ArrayList;
import java.util.List;

public class LikeFragment extends BaseFragment<LikeVideoContract.View, LikeVideoPresenter> implements LikeVideoContract.View {
    private RecyclerView like_recyclerView;

    private LikeVideoAdapter likeVideoAdapter;

    private List<LikeVideoBeanResult.LikeVideoBean> likeVideoBeanList=new ArrayList<>();

    @Override
    protected int bindLayoutId() {
        return R.layout.fragment_like;
    }

    @Override
    protected void initData() {
        presenter = new LikeVideoPresenter();
        presenter.getLikeVideos();
    }

    @Override
    protected void initView() {
        like_recyclerView = findViewById(R.id.like_recyclerView);
        like_recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
        likeVideoAdapter = new LikeVideoAdapter(likeVideoBeanList);
        like_recyclerView.setAdapter(likeVideoAdapter);
    }

    @Override
    public void onGetLikeVideosSuccess(LikeVideoBeanResult likeVideoBeanResult) {
        likeVideoBeanList.addAll(likeVideoBeanResult.getData());
        likeVideoAdapter.notifyDataSetChanged();
    }

    @Override
    public void onGetLikeVideoFailed(String error) {
        Log.i("TagA","获取点赞视频失败:"+error);
    }
}